/**
 * 20220118:由原virtualPlane分离
 */
import {BufferGeometry,Vector3,Sphere,Float32BufferAttribute} from "three";

/**
 * 虚拟平面几何体
 */
export default class VirtualPlaneGeometry extends BufferGeometry{
    constructor(){
        super();
        this._init();
    }

    //.....................................................public......................................................

    computeBoundingSphere(){
        this.boundingSphere.center.set(0,0,0);
        this.boundingSphere.radius=1;
    }

    //.....................................................private......................................................

    _init(){
        this._initVariable();
        this._initAttribute();
    }
    _initVariable(){
        this.boundingSphere=new Sphere(new Vector3(0,0,0),1);
    }
    _initAttribute(){
            let ps=new Float32Array([0,0,0,  0,0,0,  0,0,0,  0,0,0]);
            let us=new Float32Array([0,0,    0,1,    1,1,    1,0]);
            let ds=new Float32Array([-1,-1,  -1,1,   1,1,    1,-1]);
            this.setIndex([0,2,1,0,3,2]);
            this.setAttribute('position',new Float32BufferAttribute(ps,3));
            this.setAttribute('uv',new Float32BufferAttribute(us,2));
            this.setAttribute('direction',new Float32BufferAttribute(ds,2));
    }
}